using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Collections.Specialized;
using System.Drawing;
using System.Collections;

namespace TheLogWatcher
{
    public partial class MainWindow : Form
    {

        private ToolStripRenderMode renderMode;

        private void LoadWindowSettings()
        {
            listView.ListViewItemSorter = lvwColumnSorter;

            if (sets != null)
            {
                // TYPES
                if (sets.SelectedTypes == null || sets.SelectedTypes.Count == 0)
                {
                    sets.SelectedTypes = new StringCollection();
                    sets.SelectedTypes.Add(MessageTypes.ERROR.ToString());
                    sets.SelectedTypes.Add(MessageTypes.FATAL.ToString());
                    sets.Save();
                }

                // REFRESHING HISTORY
                RefreshHistoryEntries();

                // CHANGE BUTTON STATES
                changeButtonStates();

                // SETTING WINDOW POSITION & SIZE
                if (sets.MainWindowPosX == 0 || sets.MainWindowPosY == 0)
                {
                    sets.MainWindowPosX = this.Bounds.X;
                    sets.MainWindowPosY = this.Bounds.Y;
                }
                this.Bounds = new Rectangle(sets.MainWindowPosX, sets.MainWindowPosY, sets.MainWindowWidth, sets.MainWindowHeight);

                // SETTING CONSOLE FONT
                if (sets.ConsoleFont != null)
                {
                    listView.Font = sets.ConsoleFont;
                }
                
                // Setting style of controls
                if (sets.CurrentWindowStyle == 0)
                {
                    renderMode = ToolStripRenderMode.Professional;
                }
                else
                {
                    renderMode = ToolStripRenderMode.System;
                }
                contextMenuListView.RenderMode = this.renderMode;
                menuStripMainWindow.RenderMode = this.renderMode;
            }
        }


        private void SaveWindowSettings()
        {
            // Setting window size & position
            sets.MainWindowWidth = this.Width;
            sets.MainWindowHeight = this.Height;
            sets.MainWindowPosX = this.Bounds.X;
            sets.MainWindowPosY = this.Bounds.Y;

            // Saving everything
            sets.Save();
        }
    }
}
